<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: index.php 385 2014-01-18 11:43:45Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 385 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2014-01-18 11:43:45 +0000 (Sat, 18 Jan 2014) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */
include ('includes/application_top.php');

if(!isset($_GET['products_id']) && (!isset($_GET['cPath'])) && (!isset($_GET['filter_id'])) && (!isset($_GET['multisort'])) && (!isset($_GET['brand'])) && (!isset($_GET['coID'])))
	$_GET['coID'] = '5';

$smarty = new Smarty();

$category_depth = 'top';
if(isset($cPath) && not_null($cPath)) {

	$category_parent = $db->db_query("
    SELECT categories_id
    FROM ".TABLE_CATEGORIES."
    WHERE parent_id = '".$current_category_id."' and categories_status = 1");
	if($category_parent->_numOfRows)
		$category_depth = 'nested'; // Kategorie hat Unterkategorien
	else {
  	$categories_products = $db->db_query("
      SELECT categories_id
      FROM 
        ".TABLE_PRODUCTS." p
        inner join ".TABLE_PRODUCTS_TO_CATEGORIES." p2c on p.products_id = p2c.products_id
      WHERE 
        p.products_status = '1' 
        AND p2c.categories_id = '".$current_category_id."'");
  	if($categories_products->_numOfRows)
  		$category_depth = 'products'; // nur Produkte
  	else
  		$category_depth = 'empty'; // Kategorie ist leer
  }
/*
	$categories_products = $db->db_query("
    SELECT categories_id
    FROM 
      ".TABLE_PRODUCTS." p
      inner join ".TABLE_PRODUCTS_TO_CATEGORIES." p2c on p.products_id = p2c.products_id
    WHERE 
      p.products_status = '1' 
      AND p2c.categories_id = '".$current_category_id."'";
	if($categories_products->_numOfRows)
		$category_depth = 'nested'; // Kategorie
	else {
		$category_parent = $db->db_query("
      SELECT categories_id
      FROM ".TABLE_CATEGORIES."
      WHERE parent_id = '".$current_category_id."'");
		if($category_parent->_numOfRows)
			$category_depth = 'nested'; // Kategorie hat keine Produkte
		else
			$category_depth = 'products'; // Kategorie hat Produkte
	}
*/	
}

if(!isset($_GET['infinite'])) {
	include(DIR_WS_MODULES.'product_filter.php');
	require(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');
	require(DIR_WS_INCLUDES.'xajax/xajax_core/xajax.inc.php');
	require(DIR_WS_INCLUDES.'xajax/xajax.add_cart.php');
	require(DIR_WS_INCLUDES.'xajax/xajax.admin.php');
}
include(DIR_WS_MODULES.'default.php');
if(!isset($_GET['infinite'])) {
	require(DIR_WS_INCLUDES.'header.php');
	
	$smarty->assign('language', $_SESSION['language']);
	
	if(!defined('RM'))
		$smarty->loadFilter('output', 'note');
	$smarty->loadFilter('output','trimwhitespace');
	$smarty->display(CURRENT_TEMPLATE.'/index.html');
	include('includes/application_bottom.php');
}